#include<stdio.h>
#include<string.h>

char * strrev(char * str)
{
	/*char * f = str;
	while (*(f++) != NULL);
	f = f-2;
	char * h = str;
	while (h < f)
	{
		char c = *h;
		*h = *f;
		*f = c;
		h++;
		f--;
	}*/

	int length = strlen(str);
	int i;
	for (i = 0; i < length/2; i++)
	{
		char c = str[i];
		str[i] = str[length-1-i];
		str[length-1-i] = c;
	}
	return str;
}

char* itoa(int value, char*  str, int radix)
{
	int positive = 0;
	int temp = 0;
	char * c = str;
	char * s = str;
	if (value > 0)
	{
		value = -value;
		positive = 1;
	}
	if (!positive)
	{
		*c='-';
		c++;
		s++;
	}
	while(value)
	{
		temp = value%radix;
		temp = -temp;
		if (temp > 9)
		{
			*c = 'a'+(temp-10);
		}
		else
		{
			*c = '0'+temp;
		}
		c ++;
		value = value/radix;
	}
	*c = '\0';
	strrev(s);
	return str;
}

int main()
{
	char a[4];	
	printf("%s form %s\n", itoa(0xFF, a, 10), a);
    return 0;
}
